﻿using System;
using System.Collections.Generic;
using BLL;
using Model;

public partial class ANTProductPackage_TPackageTestAdd : System.Web.UI.Page
{
    TPackageTest bs;

    public ANTProductPackage_TPackageTestAdd()
    {
        bs = new TPackageTest();
    }

    protected void Page_Load(object sender, EventArgs e)
    {

    }

    protected void Button1_Click(object sender, EventArgs e)
    {
        string productSN = this.TextBox1.Text.Trim();
        TPackageTestInfo bsi = new TPackageTestInfo(productSN, DateTime.Now, User.Identity.Name);
        try
        {
            bs.Insert(bsi);
            string str = productSN + " 录入成功！";
            ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + str + "');</script>");
            this.TextBox1.Text = "";
            this.TextBox1.Focus();
        }
        catch
        {
            string str = "出现错误，请联系相关人员！";
            ClientScript.RegisterStartupScript(ClientScript.GetType(), "", "<script>alert('" + str + "');</script>");
        }
    }

    protected void Button2_Click(object sender, EventArgs e)
    {
        string productSN = this.TextBox2.Text.Trim();
        IList<TPackageTestInfo> list = new List<TPackageTestInfo>();
        list.Add(bs.LoadEntity(productSN));
        this.GridView1.DataSource = list;
        this.GridView1.DataBind();
    }
}
